﻿@using Snai.CMS.Manage.Models.BackManage

@model ModuleListModel

<div class="search-title">
    <form class="layui-form">
        <div class="layui-form-item">
            <div class="layui-input-inline">
                <input id="title" name="title" placeholder="请输入菜单名" class="layui-input" autocomplete="off">
            </div>
            <div class="layui-input-inline">
                <select id="parentID" name="parentID">
                    <option value="">请选择父类菜单</option>
                    @foreach (var moduleP in Model.Modules.Where(s => s.ParentID == 0))
                    {
                        <option value="@moduleP.ID">@moduleP.Title</option>
                        foreach (var moduleZ in Model.Modules.Where(s => s.ParentID == moduleP.ID))
                        {
                        <option value="@moduleZ.ID">&nbsp;&nbsp;&nbsp;&nbsp;@moduleZ.Title</option>
                        }
                    }
                </select>
            </div>
            <div class="layui-input-inline">
                <button type="button" id="btnReload" name="btnReload" class="layui-btn">查询</button>
            </div>
        </div>
    </form>
</div>

<script type="text/html" id="moduleToolbar">
    <div class="layui-btn-container">
        @if (Model.RoleModules.Select(s => new { s.Controller, s.Action }).Contains(new { Controller = "BackManage", Action = "ModifyModule" }))
        {
            <button class="layui-btn layui-btn-sm layui-btn-primary" lay-event="add">添加</button>
        }
        @if (Model.RoleModules.Select(s => new { s.Controller, s.Action }).Contains(new { Controller = "BackManage", Action = "UpdateModuleState" }))
        {
            <button class="layui-btn layui-btn-sm" lay-event="enable">启用</button>
            <button class="layui-btn layui-btn-sm layui-btn-warm" lay-event="disable">禁用</button>
        }
        @if (Model.RoleModules.Select(s => new { s.Controller, s.Action }).Contains(new { Controller = "BackManage", Action = "DeleteModule" }))
        {
            <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="delete">删除</button>
        }
    </div>
</script>

<table id="moduleList" lay-filter="moduleList"></table>

<script type="text/html" id="stateTpl">
    {{#  if(d.state == 1){ }}
    <p class="font-color-normal">启用</p>
    {{#  } else { }}
    <p class="font-color-danger">禁用</p>
    {{#  } }}
</script>

<script type='text/html' id='moduleBar'>
    @if (Model.RoleModules.Select(s => new { s.Controller, s.Action }).Contains(new { Controller = "BackManage", Action = "ModifyModule" }))
    {
        <a class='layui-btn layui-btn-xs' lay-event='edit'>编辑</a>
    }
</script>


@section Scripts{
    <script src="~/js/extensions.js"></script>
    <script src="~/js/utils.js"></script>
    <script src="~/js/modulelist.js"></script>
}

